package com.vip.file.controller;

import lombok.Data;

import java.io.Serializable;

/**
 * 后端统一返回结果
 * @param <T>
 */
@Data
public class ResultNew<T> implements Serializable {

    private Integer code; //编码：1成功，0和其它数字为失败
    private String msg; //错误信息
    private T data; //数据

    public static <T> ResultNew<T> success() {
        ResultNew<T> ResultNew = new ResultNew<T>();
        ResultNew.code = 1;
        return ResultNew;
    }

    public static <T> ResultNew<T> success(T object) {
        ResultNew<T> ResultNew = new ResultNew<T>();
        ResultNew.data = object;
        ResultNew.code = 1;
        return ResultNew;
    }

    public static <T> ResultNew<T> error(String msg) {
        ResultNew ResultNew = new ResultNew();
        ResultNew.msg = msg;
        ResultNew.code = 0;
        return ResultNew;
    }

}
